<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 1
      function MyName(name = "hyt", age = "18") {
        this.name = name;
        this.age = age;
        this.canDo = function () {
          console.log(`${this.name}和${this.age}`);
        };
      }
      var p = new MyName();
      p.canDo();

      // 2
      //   function add(x, ...y) {
      //     return y.reduce((acc, cur) => {
      //       acc += cur;
      //       return acc;
      //     }, 0);
      //   }

      //   console.log(add(1, 23, 4));
      //   console.log(add());

      // 3
      const deadd = (a, b) => a + b;
      console.log(deadd(2, 3)); // 输出 5

      function deadd1(a, b) {
        return a + b;
      }
      console.log(deadd1(2, 3)); // 输出 5
    </script>
  </body>
</html>
